import {INCOME_AND_EXPENDITURE_TYPE, INCOME_AND_EXPENDITURE_TYPE_LIST} from '@/const/type';
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    menuWidth: 80,
    searchLabelWidth: 120,
    labelWidth: 120,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    column: [
      {
        label: '用户',
        prop: 'userInfo',
      },
      {
        label: '用户昵称',
        prop: 'nickName',
        search: true,
        hide: true,
      },
      {
        label: '手机号',
        prop: 'phone',
        search: true,
      },
      {
        label: '宠物',
        prop: 'pet',
      },
      {
        label: '宠物名称',
        prop: 'petName',
        search: true,
        hide: true,
      },
      {
        label: '宠物编号',
        prop: 'petCode',
        search: true,
      },
      {
        label: '罐头能量',
        prop: 'canNumber',
      },
    ],
  };
};

export const detailTableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    menuWidth: 80,
    searchLabelWidth: 120,
    labelWidth: 120,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    menu: false,
    column: [
      {
        label: '收支类型',
        prop: 'type',
        type: 'select',
        clearable: true,
        searchSpan: 8,
        dicData: INCOME_AND_EXPENDITURE_TYPE_LIST,
        search: true,
      },
      {
        label: '事项',
        prop: 'configId',
        type: 'select',
        searchSpan: 12,
        clearable: true,
        dicUrl: `/core/can/config/list`,
        props: {
          label: 'name',
          value: 'id',
        },
        search: true,
      },
      {
        label: '说明',
        prop: 'details',
      },
      {
        label: '数量',
        prop: 'canNumber',
        formatter: (row) => {
          if(row){
            return `${row.type===INCOME_AND_EXPENDITURE_TYPE.INCREASE?'+':'-'}${row.canNumber}`;
          }else{
            return row.canNumber;
          }

        },
      },
      {
        label: '创建时间',
        prop: 'createTime',
        format: 'yyyy-MM-dd HH:mm:ss',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
        type: 'datetime',
        searchSpan: 16,
        searchRange: true,
        search: true,
      },
    ],
  };
};
